home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / driverkit / scsiTypes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-05  |  3.5 KB  |  135 lines

  1. /*      Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved. 
  2.  *
  3.  * scsiTypes.h - Exported API of SCSIController class.
  4.  *
  5.  * HISTORY
  6.  * 11-Feb-91    Doug Mitchell at NeXT
  7.  *      Created. 
  8.  */
  9.  
  10. #import <objc/objc.h>
  11. #import <driverkit/driverTypes.h>
  12. #import <kernserv/clock_timer.h>
  13. #import <bsd/dev/scsireg.h>
  14.  
  15. /*
  16.  * Buffers aligned to IO_SCSI_DMA_ALIGNMENT (both start and end addresses) are
  17.  * guaranteed to be legal.
  18.  */
  19. #define IO_SCSI_DMA_ALIGNMENT      64
  20.  
  21. /*
  22.  * Argument to executeRequest:buffer:client method.
  23.  */
  24. typedef struct {
  25.  
  26.         /*** inputs ***/
  27.         
  28.         unsigned char        target;         /* SCSI target ID */
  29.         unsigned char        lun;            /* logical unit */
  30.         cdb_t            cdb;            /* command descriptor block - 
  31.                                                  * one of three formats */
  32.         BOOL            read;         /* expected DMA direction 
  33.                          * (YES if read) */
  34.         int            maxTransfer;    /* maximum number of bytes to
  35.                                                  * transfer */
  36.         int            timeoutLength;  /* I/O timeout in seconds */
  37.         unsigned        disconnect:1;   /* OK to disconnect */
  38.     unsigned        cmdQueueDisable:1;
  39.                         /* disable command queueing */
  40.     unsigned        syncDisable:1;    /* disable synchronous transfer
  41.                          * negotiation */
  42.                 
  43.         unsigned        pad:25;
  44.     unsigned        cdbLength:4;    /* length of CDB in bytes
  45.                          * (optional) */
  46.            
  47.         /*** outputs ***/
  48.         
  49.         sc_status_t        driverStatus;   /* driver status */
  50.         unsigned char        scsiStatus;     /* SCSI status byte */
  51.         int            bytesTransferred; /* actual number of bytes 
  52.                                                  * transferred by DMA */
  53.     ns_time_t        totalTime;    /* total execution time */
  54.     ns_time_t        latentTime;    /* disconnect time */
  55.     esense_reply_t         senseData;    /* extended sense if
  56.                          * driverStatus = SR_IOST_CHKSV
  57.                          */
  58.  
  59. } IOSCSIRequest;
  60.  
  61. /*
  62.  * Exported protocol for SCSIController object.
  63.  */
  64. @protocol IOSCSIControllerExported
  65.  
  66. /*
  67.  * Attempt to reserve specified target and lun for calling device. Returns
  68.  * non-zero if device already reserved.
  69.  */
  70. - (int)reserveTarget         : (unsigned char)target
  71.                 lun : (unsigned char)lun
  72.                forOwner : owner;
  73.  
  74. - (void)releaseTarget         : (unsigned char)target
  75.                 lun : (unsigned char)lun
  76.                forOwner : owner;
  77.  
  78. /*
  79.  * Standard I/O methods.
  80.  *
  81.  * executeRequest requires buffers aligned to IO_SCSI_DMA_ALIGNMENT.
  82.  */
  83. - (sc_status_t) executeRequest     : (IOSCSIRequest *)scsiReq
  84.              buffer : (void *)buffer     /* data destination */
  85.               client : (vm_task_t)client;
  86.                    
  87. - (sc_status_t) resetSCSIBus;            /* reset the bus */
  88.  
  89. /*
  90.  * Convert an sc_status_t to an IOReturn.
  91.  */
  92. - (IOReturn)returnFromScStatus    : (sc_status_t)sc_status;
  93.  
  94. /*
  95.  * Determine maximum DMA which can be peformed in a single call to 
  96.  * executeRequest:buffer:client:.
  97.  */
  98. - (unsigned)maxTransfer;
  99.  
  100. /*
  101.  * Return required DMA alignment for current architecture.
  102.  */
  103. - (void)getDMAAlignment        : (IODMAAlignment *)alignment;
  104.  
  105. /*
  106.  * Allocate some well-aligned memory.
  107.  * Usage:
  108.  * 
  109.  * void *freePtr;
  110.  * void *alignedPtr;
  111.  * unsigned freeCnt;
  112.  * 
  113.  * alignedPtr = [controllerId allocateBufferOfLength:someLength
  114.  *            actualStart:&freePtr
  115.  *            actualLength:&freeCnt];
  116.  * ...
  117.  * when done...
  118.  *
  119.  * IOFree(freePtr, freeCnt);
  120.  */
  121.  
  122. - (void *)allocateBufferOfLength: (unsigned)length
  123.     actualStart : (void **)actualStart
  124.     actualLength : (unsigned *)actualLength;
  125.  
  126. @end
  127.  
  128. /*
  129.  * Public IONamedValue arrays.
  130.  */
  131. extern IONamedValue IOScStatusStrings[];
  132. extern IONamedValue IOSCSISenseStrings[];
  133. extern IONamedValue IOSCSIOpcodeStrings[];
  134.  
  135.